Hi everyone.
So in the last few days we learned how to index then select a rose from a panda's data frame with the
index operator.
I log and in this video we will index not only rose but also columns for the eye look operator.
But first of all we import pandas and we import our Summer Olympic Games medal data set and we have
a look at the first five throws.
So no surprise here.
And what we already learned we can for example select the very first row at an exposition zero.
It's uh the I like operator by passing here.
The index positions zero.
And we get here as a panda.
Serious the first row off our pandas data frame.
Now let's assume we only want to have the name of the athlete off to the first draw.
Then we can in addition slice also for the athlete.
So we make a comment here.
So the first position within the brackets here is for the index position of our rows.
And the second position here is for the index positions of our columns.
We want to select.
So here we want to select the athlete column.
And we have to apply position based indexing.
Same mess with lists an umpire race and matrices.
So our year column has them the index positions 0 1 2 3 and our athlete column has them the index position
far
and TV get them the athlete of the very first the medal and it's I say tiles.
So now what if you want to select.
For the first row the columns yes city and sport.
So let's copy and paste it.
So we want to slice for the column at an exposition 0 1 and 2.
So the therapist next thing we have to slice from index position zero and to index position of three
excluding song.
Here we get the the year.
The city in the sports column for our very first row is on its nineteen hundred ninety six and Essence
and its Aquatics and this the I operator.
It works out exactly in the same way as selecting and slicing and umpire race.
So the first position is for the row and next position and the second position is for the column and
next position and zero indexing applies as well.
And if we slice the starting points including and the ending points excluding and we can also pass a
list.
So let's copy and paste here and let's say we want again the first row but we want to have column at
an exposition to 4 6 and 8.
So let's see what we get here so the climate in exposition to a sport its aquatics column at an exposition
for its athlete I feel it highlights the climate in exposition 6 is gender.
So is a man and the column at an exposition 8 some kind of medal it's the gold medal and we can also
make some more complex queries so there is no limit on this.
So for example we want to have the column C a two four six and eight but we want to have the rows from
in the exposition 34 including until next position let's say thirty nine excluding and here we can see
we get the column sport athlete gender and medal farther rows from an exposition 34 until thirty eight
including and with the I Look operator.
We can also select the columns or complete columns so let's check it here.
Some method I log and we can say we want for all rows we want to have column four here.
So we get to a column form which is athlete and now we can check if this is the same as selecting a
column with the attribute athlete.
So we ask if some other I log all rows and the fourth column is equal to slam method athlete and that's
true and we already learned that we can alternatively also slice for the athlete column by having athlete
in brackets after summer.
So that's also possible.
So we are fierce free alternatives.
However if I only want to slice for a column I would never use the i log.
So some other athletes are smarter and better actually.
All right so let's again slice here with the spare brackets to have it complete.
So that's the third alternative.
And with this we are finished now with the session and in the next session we will burn the index operator
lock.
So I hope to see you there by.